package com.mall.common;

import java.util.HashSet;
import java.util.Set;

import com.google.common.collect.Sets;

public class Const {
	
	public static final String CURRENT_USER = "currentUser";
	public static final String EMAIL = "email";
	public static final String USERNAME = "username";
	
	
	public interface ProductListOrderBy{
		Set<String> PRICE_ASC_DESC = Sets.newHashSet("price_asc","price_desc");
		
	}
	
	public interface Cart{
		
		public static String LIMIT_NUM_FAIL = "LIMIT_NUM_FAIL";
		public static String LIMIT_NUM_SUCCESS = "LIMIT_NUM_SUCCESS";
	}
	
	public enum STATUS{
		ON_SALE(1,"在售"),OFF_SALE(2,"下架");
		private int status;
		private String descs;
		
		STATUS(int status,String descs){
			this.status = status;
			this.descs = descs;
		}

		public int getStatus() {
			return status;
		}

		public void setStatus(int status) {
			this.status = status;
		}

		public String getDescs() {
			return descs;
		}

		public void setDescs(String descs) {
			this.descs = descs;
		}
	}
	
	//订单状态
	public enum OrderStatusEnum{
		
		CANNEL(0,"已取消"),
		UNPAID(10,"未付款"),
		PAID(20,"已付款"),
		SHIPPED(40,"已发货"),
		ORDER_SUCCESS(50,"交易成功"),
		ORDER_CLOSE(60,"交易关闭");
		
		private int code;
		private String desc;
		
		private OrderStatusEnum(int code, String desc) {
			this.code = code;
			this.desc = desc;
		}
		public int getCode() {
			return code;
		}
		public void setCode(int code) {
			this.code = code;
		}
		public String getDesc() {
			return desc;
		}
		public void setDesc(String desc) {
			this.desc = desc;
		}
		
		
		public static OrderStatusEnum valueOf(int code){
			
			for(OrderStatusEnum status : values()){
				if(status.getCode() == code){
					return status;
				}
			}
			throw new RuntimeException("木有找到对应的枚举");
		}
		
	}
	
	public interface AlipayCallback{
		
		//交易目前所处的状态,
		
		String TRADE_STATUS_WAIT_BUYER_PAY = "WAIT_BUYER_PAY";
		String TRADE_STATUS_TRADE_SUCCESS = "TRADE_SUCCESS";

		String RESPONSE_SUCCESS = "success";
		String RESPONSE_FAILED= "failed";
		
	}
	
	
	public enum PaymentTypeEnum{
		ONLINE_PAY(1,"在线支付");
		
		private int code;
		private String value;
		
		private PaymentTypeEnum(int code, String value) {
			this.code = code;
			this.value = value;
		}
		public int getCode() {
			return code;
		}
		public void setCode(int code) {
			this.code = code;
		}
		public String getValue() {
			return value;
		}
		public void setValue(String value) {
			this.value = value;
		}
		
		public static PaymentTypeEnum codeOf(int code){
			
			//values()方法可以将枚举类转变为一个枚举类型的数组，
			
			for(PaymentTypeEnum type : values()){
				if(type.getCode() == code){
					return type;
				}
			}
			throw new RuntimeException("没有找到对应的枚举");
			
		}
		
	}
	
}
